package com.paic.du.lib.sort;
import com.paic.du.lib.Utils;
public class InsertSort {
	public static void shellSort(int [] ori){
		int [] steps = {1,2,3};
		int m=steps.length-1;
		while(m>=0){
			insertSort(ori, steps[m--]);
			
		}
			
	}
	
	public static void insertSort(int []ori, int step){
		for(int i=0;i<ori.length-1-step;i+=step){
			int j=0;
			int tmp=ori[i+step];
			for(;j<=i;j+=step){
				if(tmp<ori[j]){
					int k=i;
					while(k>=j){
						Utils.swap(ori, k+step, k);
						k-=step;
					}
					break;
				}
			}
		}
	}
	public static void main(String args[]){
		int[] m = {2,1,4,6,3,7,3,5,3,2,76,23};
		shellSort(m);
		
	}
}
